interface _CA_ {
    /**
     * 将数组中的每个元素进行组合
     * @param arr 数组
     * @param separator <','> 分隔符
     * @returns 数组
     */
    combination(arr: Array<any>, separator?: string): Array<string>;
}
{
    const fn = function (item1: any, item2: any, separator: string = ','): Array<string> {
        if (Array.isArray(item1)) {
            if (Array.isArray(item2)) {
                if (item1.length === 0) {
                    if (item2.length === 0) {
                        return [];
                    } else {
                        const result: Array<string> = [];
                        item2.forEach(x => { result.push(String(x)); });
                        return result;
                    }
                } else {
                    if (item2.length === 0) {
                        const result: Array<string> = [];
                        item1.forEach(x => { result.push(String(x)); });
                        return result;
                    } else {
                        let result: Array<string> = [];
                        item1.forEach(x1 => {
                            item2.forEach(x2 => {
                                result.push(`${x1}${separator}${x2}`);
                            })
                        });
                        return result;
                    }
                }
            } else {
                if (item1.length === 0) {
                    return [String(item2)];
                } else {
                    const result: Array<string> = [];
                    item1.forEach(x => { result.push(`${x}${separator}${item2}`); });
                    return result;
                }
            }
        } else {
            if (Array.isArray(item2)) {
                if (item2.length === 0) {
                    return [String(item1)];
                } else {
                    const result: Array<string> = [];
                    item2.forEach(x => { result.push(`${item1}${separator}${x}`); });
                    return result;
                }
            } else {
                return [`${item1}${separator}${item2}`];
            }
        }
    }

    Object.defineProperty(_CA_.prototype, 'combination', {
        writable: false,
        configurable: false,
        enumerable: false,
        value: function (arr: Array<any>, separator = ',') {
            let result: Array<string> = [];
            arr.forEach((item) => {
                result = fn(result, item, separator);
            });
            return result;
        }
    });
}
